#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
const int N = 1e5 + 5;

int T;
int n;
int a[N];
int b[N];
// int ans;

int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    scanf("%d",&T);
    while (T--)
    {
        scanf("%d",&n);
        for (int i=1;i<=n;i++)
            scanf("%d",&a[i]);

        int ans=0;
        for (int i=0;i<(1<<n);i++)
        {
            int sum=0;
            int pre0=0;
            int pre1=0;
            for (int j=1;j<=n;j++)
            {
                if(i&(1<<j-1))
                {
                    b[j]=1;
                    if(pre1==a[j])
                        sum+=a[j];
                    pre1=a[j];
                }
                else{
                    if(pre0==a[j])
                        sum+=a[j];
                    pre0=a[j];
                }
            }
            ans=max(ans,sum);
        }
        printf("%d\n",ans);
    }

    return 0;
}
